 

package com.zdkj.subway.rca.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.rca.service.SwCkClearRulesService;
import com.zdkj.subway.rca.service.ViewCkOperatorsRemitCatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


/**
 * 清分及划账-清分及划账报表查看-运营商划账（长安通卡)
 *
 * @author stw
 * @date 2020-12-16 11:00:18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/viewCkOperatorsRemitCat" )
@Api(value = "viewCkOperatorsRemitCat", tags = "清分及划账-清分及划账报表查看-运营商划账（长安通卡)")
public class ViewCkOperatorsRemitCatController {


    @Autowired
    private final ViewCkOperatorsRemitCatService viewCkOperatorsRemitCatService;
    @Autowired
    private final SwCkClearRulesService swCkClearRulesService;

    /**
     * 运营商下拉列表
     * @return
     */
    @ApiOperation(value = "运营商下拉列表", notes = "运营商下拉列表")
    @GetMapping("/listoperators" )
    public R listoperators() {
        return R.ok(swCkClearRulesService.getServiceMap());
    }

    /**
     * 查询
     * @param startDate
     * @param endDate
     * @param operators 
     * @return
     */
    @ApiOperation(value = "查询", notes = "查询")
    @GetMapping("/list" )
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "startDate", value = "开始日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "endDate", value = "结束日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "operators", value = "运营商编码", dataTypeClass = String.class)
            }
    )
    public R getViewCkOperatorsRemitCatList(String startDate,String endDate,String operators) {
        if(StringUtils.isEmpty(startDate) ||  StringUtils.isEmpty(endDate)){
            return R.failed("开始日期和结束日期不能为空");
        }

        return R.ok(viewCkOperatorsRemitCatService.listViewCkOperatorsRemitCat(startDate,endDate,operators));
    }


    /**
     * 导出
     * @param startDate
     * @param endDate
     * @param operators 
     * @return
     */
    @ApiOperation(value = "导出", notes = "导出")
    @GetMapping({"/export"})
    @SysLog("运营商划账（长安通卡)-导出")
    @PreAuthorize("@pms.hasPermission('view_ck_operators_remit_cat_export')")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "startDate", value = "开始日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "endDate", value = "结束日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "operators", value = "运营商编码", dataTypeClass = String.class)
            }
    )
    public void export(String startDate,String endDate,String operators, HttpServletResponse response) {
        if(StringUtils.isEmpty(startDate) ||  StringUtils.isEmpty(endDate)){
            return;
        }
        viewCkOperatorsRemitCatService.export(startDate,endDate,operators,response);

    }

}
